#pragma once

#include "effectbase.h"
#include <osg\Vec4>
#include "beamactor.h"
#include <osg\NodeCallback>

namespace VrDataCore
{
	class BeamEffectCallback;

	class VRDATACORE_EXPORT BeamEffectActor:public EffectBase
	{
	public:
		BeamEffectActor(void);
		void setDestinationPosition(const osg::Vec3& pos);
		void setDistanceWithBeam(int dis);
		void update();
	protected:
		virtual ~BeamEffectActor(void);
	public:
		virtual void apply(CoreBase::ActorBase* bindingactor);
		virtual void unApply(CoreBase::ActorBase* bindingactor);
		virtual void buildPropertyMap();
	private:
		osg::ref_ptr<BeamEffectCallback>		_beamEffectCallback;
		osg::Vec3								_destinationPosition;
		int									_distanceWithBeam;
		osg::ref_ptr<BeamActor>				_beamActor;
	};

	class BeamEffectCallback: public osg::NodeCallback
	{
	public:
		BeamEffectCallback(BeamEffectActor* bea)
		{
			_bea = bea;
		}
		virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
		{
			_bea->update();
			traverse(node, nv); 
		}
		~BeamEffectCallback(){}
		private:
			BeamEffectActor*								_bea;
	};
}